/*
 * Copyright (C) 2017 Fromentin Xavier
 *
 * This file is part of GDOB.
 *
 * GDOB is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * GDOB is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.grimdawnofflinebuilder.util.template

import com.grimdawnofflinebuilder.util.config.GDOBConfig
import com.grimdawnofflinebuilder.util.template.classGeneration.generated.impl.ArmorFeet
import com.grimdawnofflinebuilder.util.template.templateReader.toRecordsFile
import java.io.File

/**
 * DBR files reader
 */
class DBRReader {

    /**
     * Companion objects
     */
    companion object {
        val preferences = GDOBConfig.preferences
        val readerConfig = GDOBConfig.recordsReaderConfig
    }

    /**
     * Read the data in the given dbr file
     */
    fun readDBRFile( dbrFile: File) {
        val lines = dbrFile.readLines()
          .map { it.split( "," ) }
          .associateBy( { it[0] }, { it[1] } )
          .withDefault { "" }
        println( lines )
        val armorFeet01 = ArmorFeet( lines )
        println( "Success ")
    }

}

fun main( args: Array<String > ) {
    val dbrFile = """gearfeet\a01_feet01.dbr""".toRecordsFile( DBRReader.preferences, DBRReader.readerConfig )
    DBRReader().readDBRFile( dbrFile )
}


